jQuery(function($){
            
    var swiper1 = new Swiper('.nav-list', {
        slidesPerView:4,//显示数量
        freeMode : true,
        freeModeMomentumRatio: 0.5
    })
            
    swiper1.container.on("click", function(){
        var slide = swiper1.slides.eq(swiper1.clickedIndex);
        slide.addClass("active").siblings().removeClass("active");
        var swiperHalf = swiper1.width / 2;
        var maxTranslate = swiper1.maxTranslate();
        var maxWidth = -maxTranslate + swiperHalf;
        var slideLeft = slide[0].offsetLeft;
        var slideWidth = slide[0].clientWidth;
        var slideCenter = slideLeft + slideWidth / 2;
        // 被点击slide的中心点
        swiper1.setWrapperTransition(300);
        if (slideCenter < swiperHalf) {
            swiper1.setWrapperTranslate(0);
        } else if (slideCenter > maxWidth) {
            swiper1.setWrapperTranslate(maxTranslate);
        } else {
            var translate = slideCenter - swiperHalf;
            swiper1.setWrapperTranslate(-translate);
        }
        
        swiper2.slideTo(swiper1.clickedIndex);//slideTo 设置为true则点击slide时会在这个slide产生过渡
    })
           
    var swiper2 = new Swiper('.sw', {
    	pagination: '.swiper-pagination',
    	paginationClickable: true,
    	onInit: function(swiper2) {//回调函数，首次初始化后马上执行...
	   		$.ajax({
                type: "GET",
                url:"../json/gwc.json",
                dataType: 'json',
                success:function(data){
                    res = data.filter(function(v){
                        return v.number == 2;
                    });
                    var str = template("moban", {arr:res});
                    $('.ab').html(str);
                    
                }
            })
		},
        onSlideChangeEnd: function(swiper2) {//回调函数，过渡动画结束后执行，即滑块活动停止后执行
	    	swiper1.clickedIndex = swiper2.activeIndex;
            swiper1.slides.eq(swiper2.activeIndex).trigger('click');
		    $.ajax({
                type: "GET",
                url:"../json/gwc.json",
                dataType: 'json',
                success:function(data){
                    res = data.filter(function(v){
                        return v.number == 2;
                    });
                    var str = template("moban", {arr:res});
                    $('.ab').html(str);
                }
            })
		},
    })
    $('.ge-ll').click(function(){
        location.href='search.html';
    }) 
    $('.ge-lr').click(function(){
        location.href='search.html';
    });

    
    $(document).scroll(function(){
        var sc=$(this).scrollTop();
        if(sc>1000){
            $('.up').addClass('ups');
        }else{
            $('.up').removeClass('ups');
        }
    })
    strc=$(document).scrollTop();
    
    $('.up').click(function(){
        $("body,html").animate({scrollTop:0},400);
    })
})
